package time;

import java.util.Calendar;
import java.util.Date;

import org.joda.time.DateMidnight;
import org.joda.time.DateTime;

public class Interval {

	public Date start;
	public Date end;

	public Interval() {
		Calendar cal = Calendar.getInstance();
		start = cal.getTime();
		end = cal.getTime();
	}

	public static Interval today() {
		Date today = Calendar.getInstance().getTime();
		return getInterval(today, today);
	}

	public static Interval yesterday() {
		return new Interval();
	}

	public static Interval getInterval(Date startDate, Date endDate) {
		Interval interval = new Interval();
		DateMidnight startBegins = new DateMidnight(new DateTime(startDate));
		DateMidnight endBegins = new DateMidnight(new DateTime(endDate));
		endBegins = endBegins.plusDays(1);

		interval.start = startBegins.toDate();
		interval.end = endBegins.toDate();

		return interval;
	}

}
